<template>
    <table border="1"  class="table table-success table-striped-columns">
        <h2>修改等级名称</h2>
        <tr>
            <td>会员等级名称</td>
            <td><input type="text" placeholder="请输入会员等级名称" v-model="rank.Rank_Name"/></td>
        </tr>
        <tr>
            <td>会员等级 状态</td>
            <td>
                <input type="radio" :value="true" v-model="rank.Rank_State"/>启用
                <input type="radio" :value="false" v-model="rank.Rank_State"/>禁用
            </td>
        </tr>
        <tr>
            <td>最小成长值</td>
            <td><input type="text" placeholder="请输入最小成长值" v-model="rank.Rank_MinPoint"/></td>
        </tr>
        <tr>
            <td>最大成长值</td>
            <td><input type="text" placeholder="请输入最大成长值" v-model="rank.Rank_MaxPoint"/></td>
        </tr>
        <tr>
                <input type="button" value="修改" @click="Save" class="btn btn-success"/>
        </tr>
    </table>
</template>
<script setup lang="ts">

    import {ref,onMounted} from 'vue';
    import axios from 'axios';
    import {useRoute,useRouter} from 'vue-router'
    const route=useRoute();
    const router=useRouter();

    const rank=ref({
        Rank_Name: "",
        Rank_State: true,
        Rank_MinPoint: 0,
        Rank_MaxPoint: 0
    });

    onMounted(()=>{
        LoadData();
    })

    const LoadData=()=>{
        axios.get("https://localhost:7153/api/Member/FanMamberRank/ShowMamberRank",{
            params:{
                Mrid:route.params.id
            }
        })
        .then(res=>{
            rank.value=res.data;
        })
    }

    const Save=()=>{
        axios.put("https://localhost:7153//api/Member/EiditMemberRank/EiditMemberRank",rank.value)
        .then(res=>{
            if(res.data>0){
                alert('修改成功');
            }
            else{
                alert('修改失败');
            }
            router.push("/ShowMember");
        })
    }

</script>